<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>随意购商城</title>
        <!-- 新 Bootstrap 核心 CSS 文件 -->
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap/css/default.css">

        <!-- <link rel="stylesheet" href="${pageContext.request.contextPath}/css/carousel.css" > -->
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">

        <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
        <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.js"></script>

        <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
        <script src="${pageContext.request.contextPath}/css/bootstrap/js/bootstrap.min.js"></script>
        <!-- <script src="${pageContext.request.contextPath}/js/common.js"></script> -->

        <script src="${pageContext.request.contextPath}/js/bootstrapValidator.js"></script>
        <link href="${pageContext.request.contextPath}/css/bootstrapValidator.css" rel="stylesheet" />
    </head>

    <body>
        <div class="container">

            <div class="row clearfix">
                <div class="col-md-12 ">

                    <%@include file="/login.jsp" %>
                    <%@include file="/register.jsp" %>
                    <%@include file="/car.jsp" %>
                    <%--提示信息框--%>
                    <div class="modal fade" id="msgModal" role="dialog" aria-hidden="true"
                         aria-labelledby="myModalLabel">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button class="close" aria-hidden="true" type="button" data-dismiss="modal">
                                        ×
                                    </button>
                                    <h4 class="modal-title" id="msgTitle">

                                    </h4>
                                </div>
                                <div class="modal-body" id="msgBody">

                                </div>
                                <div class="modal-footer">
                                    <button class="btn btn-default" type="button" data-dismiss="modal">关闭窗口</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <ol class="breadcrumb text-right" id="info">

                        <c:choose>
                            <c:when test="${sessionScope['login']==null || sessionScope['login'].login == false}">
                                <li id="li1"><span>游客您好，欢迎来到随意购商城！</span>
                                    <a href="#loginFormModal" data-toggle="modal">[登录]</a>&nbsp;<a href="#regFormModal"
                                                                                                   data-toggle="modal">[新用户注册]</a>
                                </li>
                            </c:when>

                            <c:otherwise>
                                <li id="li1"><span>${sessionScope['login'].user.userName } 您好，欢迎来到随意购商城！</span>
                                <li><a href="#"
                                       onclick="showCart('${sessionScope.car}')">购物车
                                    <span class="badge"
                                          id="cart">${fn:length(sessionScope.car)}</span></a>
                                </li>
                                <li><a href="${pageContext.request.contextPath}/order/myOrders.action">我的订单</a></li>
                                <li><a href="${pageContext.request.contextPath}/user/user_center.jsp">个人中心</a></li>
                                <li><a href="#" onclick="logout('${pageContext.request.contextPath}')">退出登录</a></li>
                            </c:otherwise>
                        </c:choose>

                    </ol>

                    <nav class="navbar navbar-default" role="navigation">
                        <div class="navbar-header">
                            <button type="button" class="navbar-toggle" data-toggle="collapse"
                                    data-target="#bs-example-navbar-collapse-1">
                                <span class
                                              ="sr-only">Toggle navigation</span><span class="icon-bar"></span><span
                                    class="icon-bar"></span><span class="icon-bar"></span></button>
                            <a class="navbar-brand" href="${pageContext.request.contextPath}/index.action"><span
                                    class="logo">随意购</span> 商城</a>
                        </div>

                        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

                            <ul class="nav navbar-nav">
                                <c:set var="url" value="${pageContext.request.requestURL}"/>

                                <li class="${url.toString().contains("home.jsp")?"active":""}">
                                    <a href="${pageContext.request.contextPath}/index.action">首页</a>
                                </li>


                                <li class="${url.toString().contains("sale_goods.jsp")?"active":""}"><a
                                        href="${pageContext.request.contextPath}/goods/saleGoods.action">热销商品</a>
                                </li>

                                <li class="${url.toString().contains("new_goods.jsp")?"active":""}"><a
                                        href="${pageContext.request.contextPath}/goods/newGoods.action">新到商品</a>
                                </li>

                                <li class="dropdown ${url.toString().contains('goods_cate.jsp')?"active":""}">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">商品分类<strong
                                            class="caret"></strong></a>
                                    <ul class="dropdown-menu">
                                        <c:forEach items="${category}" var="c">
                                            <c:forEach items="${c}" var="cl">
                                                <li>
                                                    <a href="${pageContext.request.contextPath}/goods/goodsCate.action?childid=${cl.cateId}">${cl.cateName}</a>
                                                </li>
                                            </c:forEach>
                                            <li class="divider"></li>
                                        </c:forEach>
                                    </ul>
                                </li>
                            </ul>
                            <form class="navbar-form navbar-left" role="search" method="post"
                                  action="${pageContext.request.contextPath}/goods/searchGoods.action">
                                <div class="form-group">
                                    <input type="text" class="form-control" name="keyword" value="${param.keyword == null ? "" : param.keyword}"/>
                                </div>
                                <input type="submit" class="btn btn-default" value="店内搜索"/>
                            </form>
                            <ul class="nav navbar-nav navbar-right">

                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><c:choose>
                                        <c:when test="${param.sort == 1}">按价格从低到高</c:when>
                                        <c:when test="${param.sort == 2}">按价格从高到低</c:when>
                                        <c:when test="${param.sort == 3}">按销量从高到低</c:when>
                                        <c:when test="${param.sort == 4}">按销量从低到高</c:when>
                                        <c:otherwise>排序</c:otherwise>
                                    </c:choose>
                                        <strong class="caret"></strong></a>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a ${param.sort == 1 ? "class=\"focus\"":""} href="${pageContext.request.contextPath}/goods/goodsCate.action?childid=${param.childid==null?1:param.childid}&sort=1">按价格从低到高</a>
                                        </li>
                                        <li>
                                            <a ${param.sort == 2 ? "class=\"focus\"":""} href="${pageContext.request.contextPath}/goods/goodsCate.action?childid=${param.childid==null?1:param.childid}&sort=2">按价格从高到低</a>
                                        </li>
                                        <li class="divider"></li>
                                        <li>
                                            <a ${param.sort == 3 ? "class=\"focus\"":""} href="${pageContext.request.contextPath}/goods/goodsCate.action?childid=${param.childid==null?1:param.childid}&sort=3">按销量从高到低</a>
                                        </li>
                                        <li>
                                            <a ${param.sort == 4 ? "class=\"focus\"":""} href="${pageContext.request.contextPath}/goods/goodsCate.action?childid=${param.childid==null?1:param.childid}&sort=4">按销量从低到高</a>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </nav>